﻿using System;
using Sinacor.Infra.Service.Security.Services;
using Sinacor.Infra.Common.Exceptions;
using Sinacor.Infra.Service.ExceptionHandling;
using System.Collections.Generic;
using System.ComponentModel;

namespace Sinacor.Servico.Bovespa.Contabil.Service.ServiceImplementation
{
    /// <summary>
    /// Service.ServiceImplementation Class - ContaContabil
    /// </summary>
    [SinacorServiceBehavior]
    public class ContaContabil : ServiceContract.IContaContabil
    {
         #region Membros da interface IContaContabil

        /// <summary>
        /// Serviço irá Consultar uma lista de ContasContabeis, utilizando o parâmetro informado.
        /// </summary>
        /// <param name="request">DataContract.Request.FiltroContaContabilRequest</param>
        /// <returns>Lista de contratos de dados do tipo DataContract.Response.ContaContabilResponse</returns>
        public List<DataContract.Response.ContaContabilResponse> ConsultarContasContabeis(DataContract.Request.FiltroContaContabilRequest request)
        {
            return new Translator.BusinessEntityToDataContract.ContaContabil().ToContaContabilResponse(new BusinessLogic.ContaContabil().ConsultarContasContabeis(new Translator.DataContractToBusinessEntity.ContaContabil().ToFiltroContaContabil(request)));
        }

        /// <summary>
        /// FGualberto.7COMm - Task 6312
        /// </summary>
        /// <param name="request">DataContract.Request.FiltroHistoricoContabilRequest</param>
        /// <returns>List DataContract.Response.HistoricoContabilResponse</returns>
        public List<DataContract.Response.HistoricoContabilResponse> ConsultarHistoricosContabeis(DataContract.Request.FiltroHistoricoContabilRequest request)
        {
            BusinessLogic.ContaContabil blContaContabil = new BusinessLogic.ContaContabil();
            Translator.DataContractToBusinessEntity.HistoricoContabil translatorDCToBE = new Translator.DataContractToBusinessEntity.HistoricoContabil();
            Translator.BusinessEntityToDataContract.HistoricoContabil translatorBEToDC = new Translator.BusinessEntityToDataContract.HistoricoContabil();

            BusinessEntity.Parameter.FiltroHistoricoContabil filtro = translatorDCToBE.ToFiltroHistoricoContabil(request);

            List<BusinessEntity.HistoricoContabil> historicoContabil = blContaContabil.ConsultarHistoricosContabeis(filtro);

            return translatorBEToDC.ToHistoricoContabilResponse(historicoContabil);
        }


        #endregion
    }
}